{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  {include file="headerPrint.tpl"}
{/if}
<script type="text/javascript">
function deleteRow(bulliondetailid)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway.") && confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "bullionDelete.php?bulliondetailid="+bulliondetailid;
  }
}
</script>
<script type="text/javascript">
function bookFunction(id)
{
  document.form1.bdate.value="1";
  document.form1.submit();
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><h4>{$l_bullionDetail}</h4></center>
<div class="contentDiv">
  <table border="1" align="center" width="98%" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="4" class="table1">
      {$l_partySelect} : 
      <select name="party"  onchange="bookFunction()">
        {html_options values=$party.partyId output=$party.bullionPartyName selected={$partyId}}
      </select>
    </td>
    <td colspan="3" class="table1" nowrap>
      {$l_from} : 
      {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" time=$fromDateSelected day_value_format="%02d"}
      {$l_to} 
      {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" time=$toDate day_value_format="%02d"}
    </td>
    <td class="table1"><input type="submit" name="submitBtn" value="{$l_find}" /></td>
    {if $smarty.get.print != 1}
      <td class="table1"><a href="bullionDetail.php?print=1&fromDate={$fromDate}&toDate={$toDate}&party={$partyId}">{$l_bullionPrint}</a></td>
    {else}
    {/if}
  </tr>
  <tr class="table1">
    <th width="8%">&nbsp;</th>
    <th align="center" width="8%">Date</th>
    <th align="center" width="24%">{$l_particulars}</th>
    <th align="right" width="12%">{$l_kg}</th>
    <th align="right" width="12%">{$l_bhav}</th>
    <th align="right" width="12%">{$l_cramount}</th>
    <th align="right" width="12%">{$l_crfine}</th>
    <th align="right" width="12%" colspan="2">{$l_dramount}</th>
  </tr>
  <tr class="table2">
    <td>&nbsp;</td>
    <td align="right">{$opening.particulars}</td>
    <td align="right" style="color:green;">{if $opening.kg != 0}{$opening.kg|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.bhav != 0}{$opening.bhav|string_format:"%.2f"}{/if}</td>
    <td align="right">{if $opening.cramount != 0}{$opening.cramount|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.crfine != 0}{$opening.crfine|string_format:"%.0f"}{/if}</td>
    <td align="right">{if $opening.dramount != 0}{$opening.dramount|string_format:"%.0f"}{/if}</td>
    <td align="right" colspan="2">{if $opening.totalAmt}{$opening.totalAmt|string_format:"%..0f"}{/if}</td>
  </tr>
  {section name="sec" loop=$bullionDetail}
  <tr class="table2">
    <td>
      {if $smarty.get.print != 1}
      {if $bullionDetail[sec].bullionmasterid != $bullionDetail[$smarty.section.sec.index-1].bullionmasterid}<a href="bullionDetailList.php?print=1&bullionmasterid={$bullionDetail[sec].bullionmasterid}&partyId={$bullionDetail[sec].partyId}&bulliondate={$bullionDetail[sec].bulliondate}">Print</a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
      {if $bullionDetail[sec].bullionmasterid != $bullionDetail[$smarty.section.sec.index-1].bullionmasterid}<a href="javascript:deleteRow({$bullionDetail[sec].bulliondetailid})"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
      {if $bullionDetail[sec].bullionmasterid != $bullionDetail[$smarty.section.sec.index-1].bullionmasterid}<a href="bullionEntry.php?bullionmasterid={$bullionDetail[sec].bullionmasterid}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
      {else}
        &nbsp;
      {/if}
    </td>
    <td align="center" style="border-right:1px;" NOWRAP>{$bullionDetail[sec].bulliondate|date_format:"%d-%m-%Y"}</td>
    <td align="left" style="border-right:1px;" NOWRAP>&nbsp;&nbsp;{$bullionDetail[sec].particulars}</td>
    <td align="right" style="border-right:1px; color:green;">{if $bullionDetail[sec].kg != 0}{$bullionDetail[sec].kg|string_format:"%.0f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px;">{if $bullionDetail[sec].bhav != 0}{$bullionDetail[sec].bhav|string_format:"%.2f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px; color:red;">{if $bullionDetail[sec].cramount != 0}{$bullionDetail[sec].cramount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px; color:red;">{if $bullionDetail[sec].crfine != 0}{$bullionDetail[sec].crfine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
    <td align="right" style="border-right:1px; color:green;" colspan="2">{if $bullionDetail[sec].dramount != 0}{$bullionDetail[sec].dramount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
  </tr>
  {/section}
  <tr>
    <td colspan="10"><hr COLOR="#000000" /></td>
  </tr>
  <tr class="table1">
     <th>&nbsp;</th>
      <th align="right">Total&nbsp;&nbsp;&nbsp;</th>
      <th>&nbsp;</th>
      <th align="right" style="color:green;">{$total.kg|string_format:"%.0f"}</th>
      <th>&nbsp;</th>
      <th align="right" style="color:red;">{$total.cramount|string_format:"%.0f"}</th>
      <th align="right" style="color:red;">{$total.crfine|string_format:"%.0f"}</th>
      <th align="right" style="color:green;" colspan="2">{$total.dramount|string_format:"%.0f"}</th>
  </tr>
   <tr>
    <td colspan="11"><b style="color:green;">{if $total.netfine >= 0} Total Debit Fine:{else}</b><b style="color:red;"> Total Credit Fine:{/if} {$total.netfine|string_format:"%.0f"}</b></td>
  </tr>
  <tr>
    <td colspan="11"><b style="color:green;">{if $total.netamount >= 0} Total Debit Amount:{else}</b><b style="color:red;"> Total Credit Amount:{/if} {$total.netamount|string_format:"%.0f"}</b></td>
  </tr>
  </table>
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}